用canvas画布背景图画出来是黑色的,这是为什么? |
您所在的位置:网站首页 › canvas 背景透明 › 用canvas画布背景图画出来是黑色的,这是为什么? |
createNewImg(){ var that = this; const query = wx.createSelectorQuery() var canvas = query.select('#mycanvas') query.select('#mycanvas') .fields({ node: true, size: true }) .exec((res) => { const canvas = res[0].node const context = canvas.getContext('2d') const imaUpload = canvas.createImage() console.log() imaUpload.src ='https://www.linkedsign.cn/Photo/Beauty/ChamberOfCommerce/20210907/yqh.png' // console.log(1) imaUpload.onload = function (){
context.drawImage(imaUpload, 0, 0, 345, 550) console.log(context) const dpr = wx.getSystemInfoSync().pixelRatio canvas.width = res[0].width * dpr canvas.height = res[0].height * dpr // console.log(res[0].width) context.scale(dpr, dpr) context.fillRect(0, 0, 100, 100) context.save();
var titl = that.data.Title;
context.fillStyle='#191919'; context.textAlign='left'; context.font = 'normal bold 18px sans-serif'; context.fillText('嘻嘻哈哈', 60, 270); context.stroke(); context.save();
// context.draw(true) wx.canvasToTempFilePath({ canvasId:'mycanvas', // quality:'jpg', canvas:canvas, success:res=>{ console.log(res) that.setData({ imageUrl:res.tempFilePath }) } }) }
})
} |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |